﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebPresentation
{
    public partial class TestSession : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["loggedIn"] == "pass")
            {
                TextBox1.Visible = false;
                TextBox2.Visible = false;
                Button1.Visible = false;
                welcome.Visible = true;
                Button2.Visible = true;
            }
            else
            {
                TextBox1.Visible = true;
                TextBox2.Visible = true;
                Button1.Visible = true;
                welcome.Visible = false;
                Button2.Visible = false;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if ((TextBox1.Text.CompareTo("admin") == 0) && (TextBox2.Text.CompareTo("123456") == 0))
            {
                Session["loggedIn"] = "pass";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Session["loggedIn"] = null;
        }
    }
}